package com.gaohe.service;

import com.gaohe.mapper.GoodsMapper;
import com.gaohe.mapper.UserMapper;
import com.gaohe.pojo.Goods;
import com.gaohe.pojo.User;
import com.gaohe.untils.MybatisUntils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class UserService {
    public User findByUsername(String username) {
        SqlSession sqlSession = MybatisUntils.getSqlSession(false);
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        User user = userMapper.findByUsername(username);
        return user;
    }
    public int add(User user) {
        SqlSession sqlSession = MybatisUntils.getSqlSession(true);
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        int add = userMapper.add(user);
        return add;
    }
    public int buy(double price,String username) {
        SqlSession sqlSession = MybatisUntils.getSqlSession(true);
        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);
        int buy = userMapper.buy(price,username);
        return buy;
    }
}
